package com.antgroup.seckill.business.common.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

/**
 * @author wangxy
 * @date 2024/9/7 00:01
 */
@Service
@Slf4j
public class KafkaSender {

    @Autowired
    private KafkaTemplate<String,Object> kafkaTemplate;

    /**
     * 发送消息
     *
     * @param topic
     * @param message
     */
    public void sendMessage(String topic,String message) {
        log.info("发送消息：" + message);
        kafkaTemplate.send(topic,message);
    }
}
